// Copyright (c) 2017 Florian Klampfer <https://qwtel.com/>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>.

hy-drawer {
  width: 100%; // inline
  position: relative; // inline
  overflow: hidden; // inline
  z-index: 2; // link

  @media screen {
    // <<< link
    --hy-drawer-width: 100%;
    --hy-drawer-slide-width: calc(100% - .5rem);
    --hy-drawer-box-shadow: 0 0 1rem rgba(0, 0, 0, 0.25);
    // >>>
  }

  @media screen and (min-width: $break-point-3) {
    // <<< inline
    position: fixed;
    width: $sidebar-width;
    top: 0;
    left: 0;
    bottom: 0;
    margin-left: 0;

    &.cover {
      position: relative;
      width: 100%;
    }
    // >>>

    // <<< link
    --hy-drawer-slide-width: calc(100% - #{$sidebar-width});
    // >>>
  }

  @media screen and (min-width: $break-point-dynamic) {
    $r28: ($content-width-5 / 2) + $content-margin-5;

    width: calc(50% - #{$r28});

    // <<< link
    --hy-drawer-slide-width: calc(50% + #{$r28});
    // >>>
  }

  // <<< link
  @media screen {
    &.loaded {
      position: static;
    }
  }
  // >>>
}

.sidebar {
  // <<< inline
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  color: rgba(255, 255, 255, .75);
  text-align: center;
  z-index: 2;
  min-height: 100vh;
  // >>>

  a {
    color: #fff; // inline
    border-bottom-color: rgba(255, 255, 255, 0.2); // inline
    &:hover { border-bottom-color: #fff; } // link
  }
}

// <<<<< link
hy-drawer.loaded .sidebar {
  min-height: 100%;
}
// >>>>>

.sidebar-bg {
  // <<< inline
  position: absolute;
  top: 0;
  left: calc(50% - 50vw);
  width: 100vw;
  height: 100%;
  background: #202020 center / cover;

  &::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.05);
  }
  // >>>

  &.sidebar-overlay::after {
    background: -moz-linear-gradient(top, rgba(32,32,32,0) 0%, rgba(32,32,32,0.5) 50%, rgba(32,32,32,0) 100%); // link
    background: -webkit-linear-gradient(top, rgba(32,32,32,0) 0%,rgba(32,32,32,0.5) 50%, rgba(32,32,32,0) 100%); // link
    background: linear-gradient(to bottom, rgba(32,32,32,0) 0%,rgba(32,32,32,0.5) 50%, rgba(32,32,32,0) 100%);
  }
}

// <<<<< INLINE
.sidebar-sticky {
  position: relative;
  z-index: 3;
  max-width: $sidebar-width;
  padding: 1.5rem;
  contain: content;
}

.sidebar-about {
  .avatar {
    margin-bottom: 1.5rem
  }

  > h2 {
    margin-top: 0;
  }
}

.sidebar-nav > ul {
  list-style: none;
  padding-left: 0;
}

a.sidebar-nav-item {
  display: inline-block;
  font-weight: var(--font-weight-heading);
  line-height: 1.75;
  padding: .25rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}
// >>>>>

// <<<<< LINK
@media print {
  .sidebar {
    display: none;
  }
}

#_swipe {
  position: absolute;
  z-index: 4;
  opacity: 0.33;
  top: 5vw;
  right: 5vw;
  transform: scale(0.67);

  @media screen and (min-width: $break-point-1) {
    top: calc(50% - 48px);
    right: 10vw;
    transform: scale(1);
  }
}
// >>>>>
